package org.example.controller.actualCombat;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.pipeline.ConsolePipeline;

@Controller
@RequestMapping
//启动一个爬虫
public class PlaneSpider {
    @Autowired
    private PlaneDownloader douBanDownloader;
    @Autowired
    private PlanePipeline douBanPipeline;
    @Autowired
    private PlanePageProcessor douBanPageProcessor;
    @RequestMapping("/start")
    public void start(){
        Spider.create(douBanPageProcessor)
//                设置downloader对象
                .addUrl("https://web.telegram.org/a/#-1001713408305")
//                设置pipeline组件
                .setDownloader(douBanDownloader)
                .addPipeline(douBanPipeline)
                .addPipeline(new ConsolePipeline())
//                设置scheduler组件 可以不设置

//                设置线程数
                .thread(1)
                .start();

    }
}
